package com.woniu.controller;

import com.woniu.entity.Result;
import com.woniu.pojo.TeamPackage;
import com.woniu.service.ITeamPackageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 团队-服务包表 前端控制器
 * </p>
 *
 * @author rsw
 * @since 2022-10-12
 */
@Api(tags = "团队服务包表")
@RestController
@RequestMapping("/team-package")
    public class TeamPackageController extends BaseController{

        @Autowired
        private ITeamPackageService teamPackageservice;

        @ApiOperation("查询所有")
        @GetMapping
        public Result searchAll(){
            List<TeamPackage> listTeamPackage = teamPackageservice.list();

          return toDataResult(listTeamPackage,"查询成功") ;

        }

        @ApiOperation("添加")
        @PostMapping
        public Result add(@RequestBody TeamPackage teamPackage){

            boolean flag = teamPackageservice.save(teamPackage);
            return toResult(flag);

        }
        @ApiOperation("根据id删除")
        @DeleteMapping
        public Result delete(@RequestParam int id){
            boolean flag = teamPackageservice.removeById(id);
            return toResult(flag);
        }

         @ApiOperation("根据团队id删除")
         @DeleteMapping("/teamId")
         public Result deleteTeamId(@RequestParam(value = "teamId") int teamId){
             boolean flag = teamPackageservice.removeByteamId(teamId);
             return toResult(flag);
         }

         @ApiOperation("根据id修改")
         @PutMapping
         public Result modify(@RequestBody TeamPackage teamPackage){
             boolean flag = teamPackageservice.updateById(teamPackage);
             return toResult(flag);
         }
}

